package org.imraniqbal.mouseland;

import org.imraniqbal.engine.Item;
import org.imraniqbal.engine.Map;
import org.imraniqbal.engine.Mappable;

public class Exit extends Item {

	/**
	 * Creates an Exit at specified X and Y
	 * @param x X coordinate of Exit
	 * @param y Y coordinate of Exit
	 * @author imran
	 */
	public Exit(int x, int y) {
		super(x, y);
	}
	
	/**
	 * Once activate the exit will end the game
	 * @author imran
	 */
	@Override
	public void action(Object obj, Map map) {
		if( obj instanceof MouselandGame ) {
			((MouselandGame)obj).setWin(true);
		}

	}
	/**
	 * @author imran
	 */
	@Override
	public boolean equals(Object obj){
		if(obj instanceof Exit){
			return(((Mappable)obj).getX() == this.getX() && this.getY() == ((Mappable)obj).getY());
		}
		return false;
	}

}
